package com.woniu.controller.contemtService;

import com.github.pagehelper.PageInfo;

import com.woniu.model.contentMService.dto.AdvertisementDto;
import com.woniu.model.contentMService.entity.Advertisement;
import com.woniu.model.contentMService.entity.ColumnM;
import com.woniu.model.gh.common.Result;
import com.woniu.service.contentService.AdvertisementDtoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/adv")
public class AdvertisementDtoController {

    @Autowired
    private AdvertisementDtoService advertisementDtoService;

    /**
     * 条件分页查询
     */
//    @PostMapping("/findByPage")
//    public Result<PageInfo<AdvertisementDto>> findByPage(@RequestBody Map<String, Object> condition) {
//        PageInfo<AdvertisementDto> pageInfo = advertisementDtoService.findByPage(condition);
//        return Result.ok(pageInfo);
//    }

    @RequestMapping("/findByPage")
    public Result<PageInfo<AdvertisementDto>> findByPage(@RequestBody Map<String,Object> condition) {
        Integer pageNum = (Integer) condition.get("pageNum");
        Integer pageSize = (Integer) condition.get("pageSize");
        PageInfo<AdvertisementDto> pageInfo = advertisementDtoService.findByPage(condition, pageNum, pageSize);
        return Result.ok(pageInfo);
    }


}
